package com.example.park_2306.adapter

import android.graphics.Color
import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.base.entity.TypeEntityItem
import com.example.park_2306.R
import com.example.park_2306.databinding.ItemTypeBinding

/**
 * 分类的适配器
 */
class TypeAdapter:BaseQuickAdapter<TypeEntityItem,BaseViewHolder>(R.layout.item_type) {
    var channelId = "94349546935"

    override fun onItemViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        super.onItemViewHolderCreated(viewHolder, viewType)
        DataBindingUtil.bind<ItemTypeBinding>(viewHolder.itemView)
    }
    override fun convert(helper: BaseViewHolder, item: TypeEntityItem) {
        val binding = DataBindingUtil.getBinding<ItemTypeBinding>(helper.itemView)
        binding?.info = item

        if(item.channelid==channelId){
            binding?.typeName?.setTextColor(Color.RED)
        }else{
            binding?.typeName?.setTextColor(Color.BLACK)
        }
    }

    fun setId(id:String){
        channelId = id
        notifyDataSetChanged()
    }
}